<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>Index页面</title>
    <script src="${pageContext.request.contextPath}/static/js/jquery-3.3.1.js"></script>
</head>
<body>
<h1>Hello...小Demo</h1>

<br>
<a href="${pageContext.request.contextPath}/userPage" >用户信息</a>
<br>

<input type="button" value="点击查询" onclick="query()"/>
<br>
<div id="context"></div>

<script>
    function query() {
        $.ajax({
            url: "${pageContext.request.contextPath}/queryUserList",
            type: "POST",
            async: false,
            success: function (response) {
                if (response.status == 500) {
                    var str = "";
                    var obj = "";
                    for (var i = 0; i < response.data.length; i++) {
                        obj = response.data[i];
                        console.info(obj);
                        str += obj.id + "  " + obj.username + "   " + obj.password + " <br>";
                    }
                    $("#context").html(str);
                } else {
                    $("#context").text("查询失败");
                }

            }
        });
    }
</script>
</body>
</html>
